package com.ruoyi.shop.goods.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.shop.goods.mapper.ShopAttrMapper;
import com.ruoyi.shop.common.utils.ShopUtils;
import com.ruoyi.shop.goods.domain.ShopAttr;
import com.ruoyi.shop.goods.service.IShopAttrService;
import com.ruoyi.common.core.text.Convert;

/**
 * 商城属性Service业务层处理
 * 
 * @author xuxiang
 * @date 2023-04-27
 */
@Service
public class ShopAttrServiceImpl implements IShopAttrService 
{
    @Autowired
    private ShopAttrMapper shopAttrMapper;

	/**
	 * 查询商城属性
	 * 
	 * @param attrId 商城属性主键
	 * @return 商城属性
	 */
	@Override
	public ShopAttr selectAttrById(Long attrId) {
		return shopAttrMapper.selectAttrById(attrId);
	}

    /**
     * 查询商城属性列表
     * 
     * @param shopAttr 商城属性
     * @return 商城属性
     */
    @Override
    public List<ShopAttr> selectAttrList(ShopAttr shopAttr)
    {
        return shopAttrMapper.selectAttrList(shopAttr);
    }

    /**
     * 新增商城属性
     * 
     * @param shopAttr 商城属性
     * @return 结果
     */
    @Override
    public int insertAttr(ShopAttr shopAttr)
    {
    	shopAttr.setAttrValues(ShopUtils.comma(shopAttr.getAttrValues()));
        return shopAttrMapper.insertAttr(shopAttr);
    }

	/**
	 * 修改商城属性
	 * 
	 * @param shopAttr 商城属性
	 * @return 结果
	 */
	@Override
	public int updateAttr(ShopAttr shopAttr) {
		shopAttr.setAttrValues(ShopUtils.comma(shopAttr.getAttrValues()));
		shopAttr.setUpdateTime(DateUtils.getNowDate());
		return shopAttrMapper.updateAttr(shopAttr);
	}

	/**
	 * 批量删除商城属性
	 * 
	 * @param attrIds 需要删除的商城属性主键
	 * @return 结果
	 */
	@Override
	public int deleteAttrByIds(String attrIds) {
		return shopAttrMapper.deleteAttrByIds(Convert.toStrArray(attrIds));
	}
	
	

   
}
